<?php
/**
 * The following variables are available in this template:
 * - $this: the CrudCode object
 */
?>
<?php echo "<?php\n"; ?>
/* @var $this <?php echo $this->getControllerClass(); ?> */
/* @var $model <?php echo $this->getModelClass(); ?> */
?>

<h1>Manage <?php echo $this->pluralize($this->class2name($this->modelClass)); ?></h1>

<div class="search-form">
	<?php echo "<?php \$this->renderPartial('_search',array(
		'model'=>\$model,
	)); ?>\n"; ?>
</div><!-- search-form -->

<?php echo "<?php"; ?> $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'<?php echo $this->class2id($this->modelClass); ?>-grid',
	'dataProvider'=>$searchResult,
	'columns'=>array(
<?php
foreach($this->tableSchema->columns as $column)
{
	if($column->isPrimaryKey) {
		$output = "array('name'=>'".$column->name."','headerHtmlOptions'=>array('width'=>'32px'))";
	}
	else 
	{
		switch ($column->name) {
			case 'title':
			case 'name':
				$output = "array('name'=>'".$column->name."','value'=>'CHtml::link(\$data->".$column->name.", array(\"update\",\"id\"=>\$data->id))','type'=>'raw')";
				break;
			case 'visible':
			case 'del_flg':
				$output = "array('name'=>'".$column->name."',
			'type'=>'boolean',
			'headerHtmlOptions'=>array('width'=>'50px'),
			'htmlOptions' => array('class'=>'alc'),
		)";
				break;
			case 'rank':
			case 'sort':
			case 'price':
			case 'full_price':
			case 'sale_price':
			case 'total':
				$output = "array('name'=>'".$column->name."', 
			'type'=>'number', 
			'headerHtmlOptions'=>array('width'=>'50px'),
			'htmlOptions' => array('class'=>'alr'),
		)";
				break;
			case 'create_time':
			case 'update_time':
				$output = "array('name'=>'".$column->name."', 
			'type'=>'date', 
			'headerHtmlOptions'=>array('width'=>'80px'),
			'htmlOptions' => array('class'=>'alr'),
		)";
				break;
			default:
				$output = "'".$column->name."'";
				break;
		}
	}
	echo "\t\t".$output.",\n";
}
?>
		array(
			'class'=>'CButtonColumn',
		),
	),
)); ?>
